home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
os2tools
/
bnklysrc
/
mailsubs.c
< prev
next >
Wrap
Text File
|
1989-07-08
|
29KB
|
1,213 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software <no-Inc> */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / No-Cost<no-tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
/* */
/* */
/* This module was written by Bob Hartman */
/* */
/* */
/* BinkleyTerm Mail Control Routines */
/* */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
/* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
/* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
/* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
/* ARE ABLE TO REACH WITH THE AUTHORS. */
/* */
/* */
/* The Authors can be reached at the following addresses: */
/* */
/* Robert C. Hartman Vincent E. Perriello */
/* Spark Software VEP Software */
/* 427-3 Amherst Street 111 Carroll Street */
/* CS2032, Suite 232 Naugatuck, CT 06770 */
/* Nashua, NH 03061 */
/* */
/* FidoNet 1:132/101 FidoNet 1:141/491 */
/* Data (603) 888-8179 Data (203) 729-7569 */
/* */
/* Please feel free to contact us at any time to share your comments */
/* about our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <conio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <process.h>
#include <stdlib.h>
#include <io.h>
#include "com.h"
#include "xfer.h"
#include "zmodem.h"
#include "keybd.h"
#include "sbuf.h"
#include "sched.h"
#include "externs.h"
#include "prototyp.h"
#include "vfossil.h"
#include "find.h" /*PLF Fri 05-05-1989 23:47:35 */
static char *estring (int);
static char mail_stat (MAILP);
static int xmit_install (MAILP, int, char *); /*PLF Sat 05-06-1989 01:24:26 */
static void xmit_sort (void);
/*PLF. I'm not sure if str_dh actually needs to have global scope for this
* module --- but since I can't make any sence of the program flow I am
* giving it global scope so there is no danger of me buggering
* up any logic.
*
* I was able to isolate the reference to dta_str in xmit_install because
* that function was static to this module. I can't say the same for
* xmit_delete() and xmit_reset() -- so which ever of these gets called
* first will allocate str_dh, WHICH WILL NEVER GET DEALLOCATED. It's not
* much..less than 100 bytes...still...I don't like it. If someone who
* is more intimate with this code could clean this up I would feel
* better.
*
* Global variables will be the death of you! Stop it!!
*/
static FSCAN *str_dh = NULL;
void boss_mail (manual_mode)
int manual_mode;
{
if (!net_params)
{
status_line ("!Insufficient data for session");
set_xy ("");
}
else
{
XON_DISABLE ();
if (!CARRIER)
{
mdm_init (modem_init); /* Reinitialize the modem */
}
do_mail (alias[0].Zone, boss_net, boss_node, manual_mode);
}
}
int do_mail (bzone, bnet, bnode, manual)
int bzone;
int bnet;
int bnode;
int manual;
{
long t, timerset ();
caller = 1;
got_packet = 0;
got_arcmail = 0;
got_mail = 0;
sent_mail = 0;
no_WaZOO_Session = 0;
sprintf (junk, "%d:%d/%d", bzone, bnet, bnode);
remote_zone = bzone;
remote_net = bnet;
remote_node = bnode;
called_zone = bzone;
called_net = bnet;
called_node = bnode;
if ((!net_params) || (!nodeproc (junk)))
return (0);
if (manual && CARRIER) /* called manually maybe? */
goto process_the_damned_mail; /* yup, just do some mail */
if (manual)
try_2_connect (newnodedes.PhoneNumber); /* try to connect */
else
{
/* If this is supposed to be only local, then get out if it isn't */
if (e_ptrs[cur_event]->behavior & MAT_LOCAL)
{
if (e_ptrs[cur_event]->node_cost < 0)
{
if (newnodedes.RealCost < -e_ptrs[cur_event]->node_cost)
{
return (0);
}
}
else
{
if (newnodedes.RealCost > e_ptrs[cur_event]->node_cost)
{
return (0);
}
}
}
/* If it is supposed to be 24 hour mail only, get out if it isn't */
if (newnodelist && (!(e_ptrs[cur_event]->behavior & MAT_NOMAIL24))
&& (!(newnodedes.NodeFlags & B_CM)))
return (0);
/* If we aren't supposed to send to CM's now, get out */
if (newnodelist && (e_ptrs[cur_event]->behavior & MAT_NOCM)
&& (newnodedes.NodeFlags & B_CM))
return (0);
/* Try to connect */
if (try_1_connect (newnodedes.PhoneNumber) == -1)
return (-1);
}
process_the_damned_mail:
if (CARRIER) /* if we did, */
{
/* Clear out all the crap in case we had MNP stuff */
t = timerset (100);
while (!timeup (t))
time_release ();
CLEAR_OUTBOUND ();
CLEAR_INBOUND ();
b_session (1); /* do a mail session */
mdm_hangup ();
if (un_attended && fullscreen)
{
++hist.connects;
sb_move (historywin, HIST_CONN_ROW, HIST_COL);
sprintf (junk, "%-4d", hist.connects);
sb_puts (historywin, junk);
}
if (un_attended && (got_arcmail || got_packet || got_mail))
{
bad_call (bzone, bnet, bnode, -1);
receive_exit ();
}
return (1);
}
else
{
status_line ("+End of connection attempt");
}
return (2);
}
int handle_inbound_mail ()
{
long t, timerset (); /* used for the timeouts */
int mr; /* Modem response */
caller = 0;
remote_zone = 0;
remote_net = 0;
remote_node = 0;
inloop:
if (!(server_mode && CARRIER) && !CHAR_AVAIL ()) /* Any action from modem? */
{
time_release ();
return (0); /* No, nothing to do */
}
/* if outbound only, then return */
if ((cur_event >= 0) && (e_ptrs[cur_event]->behavior & MAT_OUTONLY))
{
time_release ();
return (0);
}
mail_only = 1;
if ((cur_event >= 0) && (e_ptrs[cur_event]->behavior & MAT_BBS))
mail_only = 0;
should_answer:
screen_blank = 0;
sb_show ();
if (server_mode && CARRIER)
goto got_carrier;
if ((mr = modem_response (100)) == 2) /* see if we got a carrier */
{
t = timerset (200); /* 2 seconds... */
while (!timeup (t))
time_release (); /* wait for other side */
}
else if ((mr == 3) && (ans_str != NULL)) /* RING detected */
{
/*
* Try to make sure we don't send out the answer string while stuff is
* still coming from the modem. Most modems don't like that kind of
* sequence (including HST's!).
*/
t = timerset (100);
while (CHAR_AVAIL () && (!timeup (t)))
{
t = timerset (100);
MODEM_IN ();
}
CLEAR_INBOUND ();
mdm_cmd_string (ans_str, 0); /* transmit the answer
* string */
goto should_answer;
}
else
{
t = timerset (6000); /* 1 minute */
while ((!timeup (t))
&& (!CHAR_AVAIL ())
&& (!KEYPRESS ()))
time_release (); /* wait for another result */
if (KEYPRESS ()) /* If aborted by user, */
{
/* FOSSIL_CHAR(); *//* eat the character */
return (1); /* and get out, */
}
goto inloop; /* else proceed along */
}
got_carrier:
if (CARRIER) /* if we have a carrier, */
{
/* Clear out all the crap in case we had MNP stuff */
t = timerset (100);
while (!timeup (t))
time_release ();
CLEAR_OUTBOUND ();
CLEAR_INBOUND ();
b_session (0); /* do a mail session */
/* We got inbound mail */
if (got_arcmail || got_packet || got_mail)
{
receive_exit ();
}
}
mdm_hangup ();
return (1);
}
void xmit_sameplace ()
{
MAILP p, p1;
/* Find the guy we just gave mail to */
p = find_mail (remote_zone, remote_net, remote_node);
remote_zone = remote_net = remote_node = 0;
if (p == NULL)
{
/* He is not there */
return;
}
/* Save our current pointer */
p1 = next_mail;
if (p != next_mail)
{
/* If it is not the one we just gave mail to, save ptr and delete */
next_mail = p;
xmit_delete ();
next_mail = p1;
}
else
{
/* It was the guy at the head of the list, so just delete him */
xmit_delete ();
}
/* If we came in with a null, leave with a null */
if (p1 == NULL)
next_mail = NULL;
return;
}
MAILP find_mail (zone, net, node)
int zone;
int net;
int node;
{
MAILP p;
p = mail_top;
while (p != NULL)
{
if ((p->zone == zone) && (p->net == net) && (p->node == node))
break;
p = p->next;
}
return (p);
}
static int xmit_install (p, zone, fname)
MAILP p;
int zone;
char *fname; /*PLF Sat 05-06-1989 01:24:03 added fname parm */
{
MAILP p1, p2;
int net, node, rettype;
#ifdef IBMC
char tnet[5], tnode[5]; /*WRA added for IBM C/2 1.1 Bug */
if (sscanf (fname, "%4s%4s.", tnet, tnode) != 2)
{
return (1);
}
if (sscanf (tnet, "%04x", &net) + sscanf (tnode, "%04x", &node) != 2)
{
return (1);
}
#else
if (sscanf (fname, "%04x%04x.", &net, &node) != 2)
{
return (1);
}
#endif
p2 = find_mail (zone, net, node);
if (p2 == NULL)
{
/* We didn't find it in what we have already */
p1 = p;
p1->net = net;
p1->node = node;
p1->zone = zone;
rettype = 0;
}
else
{
/* We found it, so we have to make sure the higher level routine knows */
p1 = p2;
rettype = 1;
}
switch (fname[9])
{
case 'C': /* Crash */
p1->mailtypes |= MAIL_CRASH;
break;
case 'H': /* Hold */
p1->mailtypes |= MAIL_HOLD;
break;
case 'F': /* Normal */
case 'O':
p1->mailtypes |= MAIL_NORMAL;
break;
case 'D': /* Direct */
p1->mailtypes |= MAIL_DIRECT;
break;
case 'R': /* Request */
p1->mailtypes |= MAIL_REQUEST;
break;
}
if (!nodefind (p1->zone, p1->net, p1->node, 0))
{
p1->mailtypes |= MAIL_UNKNOWN;
return (rettype);
}
/* If it is a held packet, we won't make a call */
if (fname[9] == 'H')
{
return (rettype);
}
/*
* in mailsubs.c, near line 430, put this in:
* if( cur_event < 0 )
* return(rettype);
*
* I have no idea what is supposed to happen here, but you can't reffer to
* e_ptrs[-1].xxx in os/2 (or in reality) when there ain't no e_ptr[-1]!!
*/
if(cur_event < 0) /*PLF Mon 05-08-1989 11:19:18 */
return(rettype);
/* If it is a crash only event and this wasn't crash, return */
if ((fname[9] != 'C') && (e_ptrs[cur_event]->behavior & MAT_CM))
{
return (rettype);
}
/* If it is not supposed to be outbound requests, go on */
if ((e_ptrs[cur_event]->behavior & MAT_NOOUTREQ) &&
(fname[9] == 'R'))
{
return (rettype);
}
/* Is this a local only event? */
if (e_ptrs[cur_event]->behavior & MAT_LOCAL)
{
/*
* If this is supposed to be only local, then get out if it isn't
*/
if (e_ptrs[cur_event]->node_cost >= 0)
{
if (newnodedes.RealCost > e_ptrs[cur_event]->node_cost)
{
return (rettype);
}
}
else
{
if (newnodedes.RealCost < -e_ptrs[cur_event]->node_cost)
{
return (rettype);
}
}
}
/* Is this a non-mail window event? */
if (newnodelist && (!(e_ptrs[cur_event]->behavior & MAT_NOMAIL24)))
{
/* If this guy can't handle crash, get out and try again */
if (!(newnodedes.NodeFlags & B_CM))
{
return (rettype);
}
}
/* Is this a non-CM event? */
if (newnodelist && (e_ptrs[cur_event]->behavior & MAT_NOCM) &&
(newnodedes.NodeFlags & B_CM))
{
return (rettype);
}
/* See if we spent too much calling him already */
if (bad_call (p1->zone, p1->net, p1->node, 0))
{
p1->mailtypes |= MAIL_TOOBAD;
return (rettype);
}
p1->mailtypes |= MAIL_WILLGO;
return (rettype);
}
static char mail_stat (p)
MAILP p;
{
if (p->mailtypes & MAIL_UNKNOWN)
return ('!');
if (p->mailtypes & MAIL_TOOBAD)
return ('x');
if (p->mailtypes & MAIL_TRIED)
return ('#');
if (p->mailtypes & MAIL_WILLGO)
return ('*');
return ('-');
}
void xmit_window (p1)
MAILP p1;
{
MAILP p;
int i;
char j[40];
char j1[40];
if (!fullscreen)
return;
p = p1;
sb_fillc (holdwin, ' ');
if (p == NULL)
{
sb_move (holdwin, 3, 5);
sb_puts (holdwin, "Nothing in Outbound Area");
return;
}
sb_move (holdwin, 1, 2);
sb_puts (holdwin, "Node C H D N R S");
for (i = 2; i < 6; i++)
{
if (p == NULL)
break;
sb_move (holdwin, i, 2);
sprintf (j, "%d:%d/%d", p->zone, p->net, p->node);
sprintf (j1, "%-17.17s %c %c %c %c %c %c", j,
(p->mailtypes & MAIL_CRASH ) ? '*' : ' ',
(p->mailtypes & MAIL_HOLD ) ? '*' : ' ',
(p->mailtypes & MAIL_DIRECT ) ? '*' : ' ',
(p->mailtypes & MAIL_NORMAL ) ? '*' : ' ',
(p->mailtypes & MAIL_REQUEST) ? '*' : ' ',
mail_stat (p));
sb_puts (holdwin, j1);
p = p->next;
}
p = mail_top;
for (; i < 6; i++)
{
if ((p == p1) || (p == NULL))
break;
sb_move (holdwin, i, 2);
sprintf (j, "%d:%d/%d", p->zone, p->net, p->node);
sprintf (j1, "%-17.17s %c %c %c %c %c %c", j,
(p->mailtypes & MAIL_CRASH ) ? '*' : ' ',
(p->mailtypes & MAIL_HOLD ) ? '*' : ' ',
(p->mailtypes & MAIL_DIRECT ) ? '*' : ' ',
(p->mailtypes & MAIL_NORMAL ) ? '*' : ' ',
(p->mailtypes & MAIL_REQUEST) ? '*' : ' ',
mail_stat (p));
sb_puts (holdwin, j1);
p = p->next;
}
sb_show ();
}
static void xmit_sort ()
{
MAILP p, p1, p2;
p = mail_top;
/* Find the first that is sendable */
while (p != NULL)
{
if ((p->mailtypes & MAIL_WILLGO) &&
(!(p->mailtypes & MAIL_TOOBAD)) &&
(!(p->mailtypes & MAIL_UNKNOWN)))
break;
p = p->next;
}
if (p == NULL)
return;
/* Put the first sendable one on top */
if (p != mail_top)
{
p->prev->next = p->next;
if (p->next != NULL)
p->next->prev = p->prev;
p->prev = NULL;
p->next = mail_top;
mail_top->prev = p;
mail_top = p;
}
p1 = p;
p = p1->next;
while (p != NULL)
{
if ((p->mailtypes & MAIL_WILLGO) &&
(!(p->mailtypes & MAIL_TOOBAD)) &&
(!(p->mailtypes & MAIL_UNKNOWN)))
{
if (p->prev == p1)
{
p1 = p;
p = p->next;
continue;
}
p2 = p->next;
p->prev->next = p->next;
if (p->next != NULL)
p->next->prev = p->prev;
p->next = p1->next;
if (p1->next != NULL)
p1->next->prev = p;
p->prev = p1;
p1->next = p;
p1 = p;
p = p2;
}
else
{
p = p->next;
}
}
}
void xmit_reset ()
{
MAILP p;
int i, j, done, zone;
/* First get rid of all the old junk */
p = mail_top;
if (p != NULL)
{
while (p->next != NULL)
p = p->next;
while (p->prev != NULL)
{
p = p->prev;
free (p->next);
}
if (p != NULL)
free (p);
}
p = mail_top = NULL;
zone = alias[0].Zone;
if( !str_dh ) str_dh = opendir(); /*PLF Sat 05-06-1989 01:35:26 */
while (zone > 0)
{
i = 0;
while (outb[i] != NULL)
{
sprintf (next_one, "%s%s", HoldAreaNameMunge(zone), outb[i++]);
done = 0;
j = 0;
while (!done)
{
/* See if we have any more at this level */
/*PLF if (dfind (&dta_str, next_one, j)) */
if ( (j) ? findnext(str_dh) : findfirst(next_one, _A_NORMAL, str_dh) ) /*PLF this is ugly but preserves the old logic */
{
/* No more at this level, so go to next level */
done = 1;
}
else
{
/* We found a name, remember it */
if (p == NULL)
{
p = mail_top = (MAILP) calloc (sizeof (MAIL), 1);
}
else
{
p->next = (MAILP) calloc (sizeof (MAIL), 1);
p->next->prev = p;
p = p->next;
}
if (xmit_install (p, zone, str_dh->name))
{
/* No good */
if (p->prev != NULL)
{
p = p->prev;
free (p->next);
p->next = NULL;
}
else
{
free (p);
p = mail_top = NULL;
}
}
++j;
}
}
}
if (no_zones)
break;
/* Get the next zone number */
zone = nodefind (-1, 0, 0, 0);
if (zone == alias[0].Zone)
zone = nodefind (-1, 0, 0, 0);
}
next_mail = NULL;
xmit_sort ();
xmit_window (mail_top);
}
int xmit_next (zone, net, node)
int *zone, *net, *node;
{
/* Set up the proper pointer */
if ((next_mail == NULL) || (next_mail->next == NULL))
{
next_mail = mail_top;
}
else
{
next_mail = next_mail->next;
}
/* Loop through till we find something we can send */
while (next_mail != NULL)
{
if ((next_mail->mailtypes & MAIL_WILLGO) &&
(!(next_mail->mailtypes & MAIL_UNKNOWN)) &&
(!(next_mail->mailtypes & MAIL_TOOBAD)))
{
if (bad_call (next_mail->zone, next_mail->net, next_mail->node, 0))
{
next_mail->mailtypes |= MAIL_TOOBAD;
}
else
{
*zone = next_mail->zone;
*net = next_mail->net;
*node = next_mail->node;
xmit_window (next_mail);
return (1);
}
}
next_mail = next_mail->next;
}
/* Read the disk again since we reached the end of the list */
/* I commented this out because I think it is better just to do it
every 10 minutes */
/* xmit_reset (); */
next_mail = mail_top;
/* Try the new list and see what happens */
while (next_mail != NULL)
{
if ((next_mail->mailtypes & MAIL_WILLGO) &&
(!(next_mail->mailtypes & MAIL_UNKNOWN)) &&
(!(next_mail->mailtypes & MAIL_TOOBAD)))
{
if (bad_call (next_mail->zone, next_mail->net, next_mail->node, 0))
{
next_mail->mailtypes |= MAIL_TOOBAD;
}
else
{
*zone = next_mail->zone;
*net = next_mail->net;
*node = next_mail->node;
xmit_window (next_mail);
return (1);
}
}
next_mail = next_mail->next;
}
/* Oh well, we tried */
xmit_window (mail_top);
return (0);
}
void xmit_delete ()
{
MAILP p;
int i;
if (next_mail == NULL)
return;
if(!str_dh) str_dh = opendir(); /*PLF Sat 05-06-1989 01:47:35 */
i = 0;
while (outb[i] != NULL)
{
sprintf (next_one, "%s%04x%04x.%s",
HoldAreaNameMunge(next_mail->zone),
next_mail->net, next_mail->node, &(outb[i++][2]));
if (!findfirst(next_one, _A_NORMAL, str_dh))
{
status_line ("!Still have mail for %d:%d/%d",
next_mail->zone, next_mail->net, next_mail->node);
/* We still have something for him */
next_mail->mailtypes &= ~MAIL_WILLGO;
next_mail->mailtypes |= MAIL_TRIED;
return;
}
}
if (next_mail != mail_top)
{
p = next_mail->next;
next_mail = next_mail->prev;
free (next_mail->next);
next_mail->next = p;
if (p != NULL)
p->prev = next_mail;
xmit_window (next_mail);
}
else
{
mail_top = mail_top->next;
free (next_mail);
if (mail_top != NULL)
mail_top->prev = NULL;
xmit_window (mail_top);
next_mail = NULL;
}
}
void receive_exit ()
{
char junk1[150];
if (got_arcmail && (cur_event >= 0) && (e_ptrs[cur_event]->errlevel[2]))
{
status_line (":Exit after compressed mail with errorlevel %d",
e_ptrs[cur_event]->errlevel[2]);
errl_exit (e_ptrs[cur_event]->errlevel[2]);
}
if ((got_mail || got_packet) &&
(cur_event >= 0) && (e_ptrs[cur_event]->errlevel[1]))
{
status_line (":Exit after receiving mail with errorlevel %d",
e_ptrs[cur_event]->errlevel[1]);
errl_exit (e_ptrs[cur_event]->errlevel[1]);
}
if ((aftermail != NULL) && (got_mail || got_packet || got_arcmail))
{
status_line (":Received mail, running 'AfterMail' program");
mdm_init (modem_busy);
DTR_OFF ();
scr_printf ("\033[H\033[2J");
vfossil_cursor (1);
strcpy (junk1, aftermail);
if (cur_event >= 0)
strcat (junk1, e_ptrs[cur_event]->cmd);
close_up ();
b_spawn (junk1);
come_back ();
DTR_ON ();
status_line ("#Re-enabling system following 'AfterMail' program");
mdm_init (modem_init);
xmit_reset ();
}
got_arcmail = 0;
got_packet = 0;
got_mail = 0;
}
void errl_exit (n)
int n;
{
write_sched ();
status_line ("+end, %s", xfer_id);
mdm_init (modem_busy); /* Reinitialize the modem */
DTR_OFF (); /* Drop DTR to avoid calls */
/*SCB*/ if (fullscreen)
gotoxy (0, 23);
if (vfossil_installed)
vfossil_close ();
if (!share)
MDM_DISABLE ();
exit (n);
}
long random_time (x)
int x;
{
int i;
long timerset ();
if (x == 0)
{
return (0L);
}
/* Number of seconds to delay is random based on x +/- 50% */
i = (rand () % (x + 1)) + (x / 2);
return (timerset (i * 100));
}
char *HoldAreaNameMunge(bzone)
int bzone;
{
static char munged[80];
register char *p, *q;
p = hold_area;
if ((bzone == alias[0].Zone) || (no_zones))
return(p);
q = munged;
while (*p)
*q++ = *p++;
--q;
sprintf(q,".%03x\\",bzone);
return(munged);
}
static char fname[80];
static char fname1[80];
int bad_call (bzone, bnet, bnode, rwd)
int bzone;
int bnet;
int bnode;
int rwd;
{
int res;
int i, j;
FSCAN *bad_dh; /*PLF Fri 05-05-1989 23:36:38 */
FILE *bad_wazoo;
char *p;
char *HoldName;
HoldName = HoldAreaNameMunge(bzone);
sprintf (fname, "%s%04x%04x.$$?", HoldName, bnet, bnode);
j = strlen (fname) - 1; /* Point at ? */
res = -1; /* Initialize to fail */
bad_dh = opendir(); /*PLF Fri 05-05-1989 23:37:13 */
i = 0; /* This says findfirst */
/* as long as we match */
/*PLF while (!dfind (&bad_dh, fname, i)) */
while (!( (i) ? findnext(bad_dh) : findfirst(fname, _A_NORMAL, bad_dh) )) /*PLF Fri 05-05-1989 23:45:28 */
{
if (isdigit (bad_dh->name[11])) /* is there a digit? */
{
fname[j] = bad_dh->name[11]; /* Yes, copy to fname */
res = fname[j] - '0'; /* Save it for testing */
break; /* Get out of while */
}
else i = 1; /* Else use findnext */
}
closedir(bad_dh); /*PLF Fri 05-05-1989 23:47:06 */
if (res == -1) /* Successful search? */
{
fname[j] = '0'; /* No, base digit = 0 */
}
if (rwd > 0)
{
/* Writing a bad call */
/* First create a filename that is one higher than what we've got */
strcpy (fname1, fname);
fname1[j]++;
if (fname1[j] > '9')
fname1[j] = '9';
if (res == -1) /* Did we have a file? */
{ /* No, make one. */
if (rwd == 2) /* No carrier */
res = open (fname, O_CREAT + O_WRONLY + O_BINARY, S_IWRITE);
else /* With carrier */ res = open (fname1, O_CREAT + O_WRONLY + O_BINARY, S_IWRITE);
i = rwd - 1; /* zero-based count */
write (res, (char *) &i, sizeof (int)); /* write it out */
close (res); /* close the file */
}
else
{ /* There was a file */
/*
* 2 = Unsuccessful, No carrier. Update contents of the file.
*/
if (rwd == 2)
{
i = open (fname, O_RDONLY + O_BINARY);
read (i, (char *) &res, sizeof (int));
close (i);
++res;
i = open (fname, O_CREAT + O_WRONLY + O_BINARY, S_IWRITE);
write (i, (char *) &res, sizeof (int));
close (i);
}
/*
* 1 = Unsuccessful, Carrier. Update file name to reflect the
* failure.
*/
else
{
rename (fname, fname1);
}
}
}
else if (rwd == 0)
{
/*
* 0 = We are reading a bad call status
*/
/* Is it automatically ok (no .$$ file there) ? */
if (res == -1)
return (0);
/* Were there too many connects with carrier? */
if (res >= max_connects)
return (1);
/* Ok, check for connects without carrier */
res = 0;
i = open (fname, O_RDONLY + O_BINARY);
read (i, (char *) &res, sizeof (int));
close (i);
return (res >= max_noconnects);
}
else
{
/*
* -1 = Cleanup of bad call status. This happens in two steps: a)
* delete 'netnode.$$?' in hold area; b) if a 'netnode.Z' file exists in
* hold area, 1) delete all BADWAZOO.xxx files listed in the .Z file; 2)
* delete the 'netnode.z' file.
*/
if (res != -1)
{
unlink (fname);
}
if (!mail_finished)
return (0);
sprintf (fname, "%s%04x%04x.Z", HoldName, bnet, bnode);
if (dexists (fname))
{
errno = 0;
bad_wazoo = fopen (fname, read_ascii);
if (!got_error (OPEN_msg, fname))
{
while (!feof (bad_wazoo))
{
e_input[0] = '\0';
if (!fgets (e_input, 64, bad_wazoo))
break;
/* Point to BADWAZOO.xxx */
p = strchr (e_input, ' ') + 1;
/* Then just past it and terminate */
p = strchr (p, ' ');
*p = '\0';
/* Back to where we were */
p = strchr (e_input, ' ') + 1;
/* Build file name and delete file */
strcpy (fname1, CurrentNetFiles);
strcat (fname1, p);
unlink (fname1);
}
fclose (bad_wazoo);
}
unlink (fname);
}
}
return (0);
}
void mailer_banner ()
{
if (fullscreen && un_attended)
{
vfossil_cursor (0);
sb_move (settingswin, SET_EVNT_ROW, SET_COL);
sprintf (junk, "%-2d", cur_event + 1);
sb_puts (settingswin, junk);
sprintf (junk, "%-5u Com%d", cur_baud, port_ptr + 1);
sb_move (settingswin, SET_PORT_ROW, SET_COL);
sb_puts (settingswin, junk);
clear_filetransfer ();
}
set_baud (max_baud, 0);
}
void clear_filetransfer ()
{
if (fullscreen)
sb_fillc (filewin, ' ');
}
static char ebuf[10];
static char *estring (e)
int e;
{
ebuf[0] = '\0';
if (e >= 0)
{
if (e_ptrs[e]->behavior & MAT_BBS)
strcat (ebuf, "B");
if (e_ptrs[e]->behavior & MAT_CM)
strcat (ebuf, "C");
if (e_ptrs[e]->behavior & MAT_DYNAM)
strcat (ebuf, "D");
if (e_ptrs[e]->behavior & MAT_NOCM)
strcat (ebuf, "K");
if (e_ptrs[e]->behavior & MAT_LOCAL)
strcat (ebuf, "L");
if (e_ptrs[e]->behavior & MAT_NOREQ)
strcat (ebuf, "N");
if (e_ptrs[e]->behavior & MAT_OUTONLY)
strcat (ebuf, "S");
if (e_ptrs[e]->behavior & MAT_NOOUT)
strcat (ebuf, "R");
}
return (ebuf);
}
void do_ready (str)
char *str;
{
if (fullscreen)
{
if (!doing_poll)
{
clear_filetransfer ();
}
sb_move (settingswin, SET_EVNT_ROW, SET_COL);
sprintf (junk, "%-2d/%-6.6s", cur_event + 1, estring (cur_event));
sb_puts (settingswin, junk);
sb_move (settingswin, SET_STAT_ROW, SET_COL);
sb_puts (settingswin, str);
sb_show ();
}
}